package com.hong.demo.springboot.es.repository.mysql;

import com.hong.demo.springboot.es.entity.mysql.MySQLBlog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface MySQLBlogRepository extends JpaRepository<MySQLBlog, Integer> {
    @Query("select e from MySQLBlog e order by e.createTime desc ")
    List<MySQLBlog> queryAll();

    @Query("select e from MySQLBlog e where e.title " +
            "like concat('%',:keyword, '%') or e.content like concat('%',:keyword, '%')")
    List<MySQLBlog> queryBlogs(@Param("keyword") String keyword);
}
